package org.mock.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mock.common.Condition;
import org.mock.dto.TravelHotelPriceCheckDTO;
import org.mock.entity.TravelHotelPriceCheck;
import org.mock.mapper.TravelHotelPriceCheckMapper;
import org.mock.service.TravelHotelPriceCheckService;
import org.mock.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 *
 * @author AI
 * @since 2025-06-11
 */
@Service
@AllArgsConstructor
@Slf4j
public class TravelHotelPriceCheckServiceImpl implements TravelHotelPriceCheckService {

    protected TravelHotelPriceCheckMapper travelHotelPriceCheckMapper;

    @Override
    public TravelHotelPriceCheckDTO handleRequest(JSONObject request) {
        log.info("[priceCheck] 请求：{}", request);
        TravelHotelPriceCheckDTO dto = new TravelHotelPriceCheckDTO();

        return dto;
    }

    @Override
    public TravelHotelPriceCheckDTO handleQueryWrapper(TravelHotelPriceCheckDTO dto) {
        return dto;
    }

    @Override
    public String handleData(TravelHotelPriceCheck data) {
        if (ObjectUtil.isEmpty(data)) {
            log.info("暂无数据");
            return StrUtil.EMPTY;
        }
        return data.getResponse();
    }

    @Override
    public TravelHotelPriceCheck getOne(TravelHotelPriceCheckDTO dto) {
        List<TravelHotelPriceCheck> list = travelHotelPriceCheckMapper.selectList(Condition.getQueryWrapper(BeanCopyUtils.copy(dto, TravelHotelPriceCheck.class)));
        if (CollUtil.isEmpty(list)) {
            return null;
        } else {
            return list.get(0);
        }
//        return travelHotelDetailMapper.selectOne(Condition.getQueryWrapper(BeanCopyUtils.copy(dto,TravelHotelDetail.class)));
    }
}
